package com.shujia.jichu

/**
 * 函数的递归：函数内部调用函数自身的现象，叫做递归
 */
object Demo5FunDiGui {
  def main(args: Array[String]): Unit = {
    //求5的阶乘
    val res1: Int = jieCheng(5)
    println(s"5的阶乘是${res1}")

  }

  def jieCheng(i: Int): Int = {
    if (i == 1) {
      1
    } else {
      i * jieCheng(i - 1)
    }
  }

}
